﻿
@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<div class="row" id="app">
    <div class="col-xs-12">
        <!-- PAGE CONTENT BEGINS -->
        <form class="form-horizontal" role="form">
            <!-- #section:elements.form -->
            <div class="form-group">
                <label class="col-sm-3 control-label no-padding-right" for="form-field-1"> 旧密码 </label>

                <div class="col-sm-9">
                    <input type="password" id="form-field-1" placeholder="旧密码" class="col-xs-10 col-sm-5" v-model="oldpassword" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label no-padding-right" for="form-field-2"> 新密码 </label>

                <div class="col-sm-9">
                    <input type="password" id="form-field-2" placeholder="新密码" class="col-xs-10 col-sm-5" v-model="newpassword" />
                </div>
            </div>
            <div class="clearfix form-actions">
                <div class="col-md-offset-3 col-md-9">
                    <button class="btn btn-info" type="button" v-on:click="p_ChangePassword()">
                        <i class="ace-icon fa fa-check bigger-110"></i>
                        修改密码
                    </button>
                </div>
            </div>

            <div class="hr hr-24"></div>
        </form>
    </div>
</div>
<script type="text/javascript">
    var vm = new Vue({
        el: '#app',
        data: {
            oldpassword: "",
            newpassword: ""
        },
        methods: {
            p_ChangePassword: function () {
                var _self = this;
                if (_self.oldpassword == "" || _self.newpassword == "") {
                    bootbox.alert("原密码和新密码必需填写");
                    return;
                }
                bootbox.confirm("你确定这个操作吗?",
                    function(result) {
                        if (result) {
                            debugger;
                            var readyData = { oldpassword: _self.oldpassword, newpassword: _self.newpassword};
                            axios.post("@Url.Action("ChangePassword", "PersonalCenter")", readyData).then((response) => {
                                    bootbox.alert("成功", function() {
                                    });
                                },
                                (response) => {

                                }
                            ).catch(function(response) {
                                console.log(response);
                            });
                        }
                    });
            },
            Init: function() {

            }
        },
        created() {
            //console.log("页面初始化完成111");
        },
        mounted() {
        }
    });
</script>